-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
reorganize sequence 2 sequence. #112
Conversation
28f9377
to
107d31e
Compare
96a1cff
to
00eb42a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost LGTM
nmt_without_attention/README.md
Outdated
@@ -84,19 +85,17 @@ encoded_vector = paddle.networks.bidirectional_gru( | |||
|
|||
|
|||
### 无注意力机制的解码器 | |||
PaddleBook中[机器翻译](https://github.com/PaddlePaddle/book/blob/develop/08.machine_translation/README.cn.md)的相关章节中,已介绍了带注意力机制(Attention Mechanism)的 Encoder-Decoder 结构,本例则介绍的是不带注意力机制的 Encoder-Decoder 结构。关于注意力机制,读者可进一步参考 PaddleBook 和参考文献\[[3](#参考文献)]。 | |||
-PaddleBook中[机器翻译](https://github.com/PaddlePaddle/book/blob/develop/08.machine_translation/README.cn.md)的相关章节中,已介绍了带注意力机制(Attention Mechanism)的 Encoder-Decoder 结构,本例则介绍的是不带注意力机制的 Encoder-Decoder 结构。关于注意力机制,读者可进一步参考 PaddleBook 和参考文献\[[3](#参考文献)]。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"本例则介绍的是" -> "本例介绍的则是"? 感觉会好一点
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nmt_without_attention/README.md
Outdated
* `prob`表示生成句子的得分,随之其后则是翻译生成的句子; | ||
* `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 | ||
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
第二 ~ beam_size + 1
行 -> 第二至第beam_size + 1
行,
在文字中少用符号是不是有好点?anyway,个人偏好。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
nmt_without_attention/README.md
Outdated
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 | ||
- 一行之内以“\t”分隔为两列,第一列是句子的log 概率,第二列是翻译结果的文本。 | ||
- `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<s>
-> 符号<s>
, <unk>
-> 符号<unk>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -198,22 +193,25 @@ else: | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to reorganize line 189 because we don't have params --train
and --generate
now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
nmt_without_attention/README.md
Outdated
* `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 | ||
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 | ||
- 一行之内以“\t”分隔为两列,第一列是句子的log 概率,第二列是翻译结果的文本。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
一行之内 -> 相同行的输出
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nmt_without_attention/generate.py
Outdated
def generate(source_dict_dim, target_dict_dim, model_path, beam_size, | ||
batch_size): | ||
""" | ||
sequence generation for NMT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sequence -> Sequence
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
nmt_without_attention/generate.py
Outdated
|
||
if __name__ == "__main__": | ||
generate( | ||
source_dict_dim=3000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
source_dict_dim
is 30000 in the original configuration. Should 3000 be OK? the same in train.py
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bug. fix this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow comments.
nmt_without_attention/README.md
Outdated
@@ -84,19 +85,17 @@ encoded_vector = paddle.networks.bidirectional_gru( | |||
|
|||
|
|||
### 无注意力机制的解码器 | |||
PaddleBook中[机器翻译](https://github.com/PaddlePaddle/book/blob/develop/08.machine_translation/README.cn.md)的相关章节中,已介绍了带注意力机制(Attention Mechanism)的 Encoder-Decoder 结构,本例则介绍的是不带注意力机制的 Encoder-Decoder 结构。关于注意力机制,读者可进一步参考 PaddleBook 和参考文献\[[3](#参考文献)]。 | |||
-PaddleBook中[机器翻译](https://github.com/PaddlePaddle/book/blob/develop/08.machine_translation/README.cn.md)的相关章节中,已介绍了带注意力机制(Attention Mechanism)的 Encoder-Decoder 结构,本例则介绍的是不带注意力机制的 Encoder-Decoder 结构。关于注意力机制,读者可进一步参考 PaddleBook 和参考文献\[[3](#参考文献)]。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nmt_without_attention/README.md
Outdated
* `prob`表示生成句子的得分,随之其后则是翻译生成的句子; | ||
* `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 | ||
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
nmt_without_attention/README.md
Outdated
* `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 | ||
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 | ||
- 一行之内以“\t”分隔为两列,第一列是句子的log 概率,第二列是翻译结果的文本。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nmt_without_attention/README.md
Outdated
- 第一行为输入的源语言句子。 | ||
- 第二 ~ `beam_size + 1` 行是柱搜索生成的 `beam_size` 条翻译结果 | ||
- 一行之内以“\t”分隔为两列,第一列是句子的log 概率,第二列是翻译结果的文本。 | ||
- `<s>` 表示句子的开始,`<e>`表示一个句子的结束,如果出现了在词典中未包含的词,则用`<unk>`替代。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nmt_without_attention/generate.py
Outdated
|
||
if __name__ == "__main__": | ||
generate( | ||
source_dict_dim=3000, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bug. fix this.
nmt_without_attention/generate.py
Outdated
def generate(source_dict_dim, target_dict_dim, model_path, beam_size, | ||
batch_size): | ||
""" | ||
sequence generation for NMT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
@@ -198,22 +193,25 @@ else: | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great. LGTM
reorganize codes of attention without attention.